import 'package:flutter/material.dart';
import '../constants/app_colors.dart';
import '../constants/app_theme.dart';
import 'hand_drawn_icon.dart';

class MoodSelector extends StatelessWidget {
  final String title;
  final int selectedMood;
  final Function(int) onMoodSelected;
  final bool showLabels;

  const MoodSelector({
    Key? key,
    required this.title,
    required this.selectedMood,
    required this.onMoodSelected,
    this.showLabels = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 24),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            _buildMoodOption(context, 1, '😢', '很差', AppColors.moodVeryBad),
            _buildMoodOption(context, 2, '😕', '较差', AppColors.moodBad),
            _buildMoodOption(context, 3, '😐', '一般', AppColors.moodNeutral),
            _buildMoodOption(context, 4, '🙂', '较好', AppColors.moodGood),
            _buildMoodOption(context, 5, '😄', '很好', AppColors.moodVeryGood),
          ],
        ),
      ],
    );
  }

  Widget _buildMoodOption(BuildContext context, int moodType, String emoji, String label, Color color) {
    final isSelected = selectedMood == moodType;
    
    return GestureDetector(
      onTap: () => onMoodSelected(moodType),
      child: Column(
        children: [
          Container(
            width: 60,
            height: 60,
            decoration: BoxDecoration(
              color: isSelected ? color.withOpacity(0.3) : Colors.white,
              borderRadius: BorderRadius.circular(16),
              border: Border.all(
                color: isSelected ? color : Colors.grey.shade300,
                width: 1.5,
              ),
              boxShadow: isSelected
                  ? [
                      BoxShadow(
                        color: color.withOpacity(0.2),
                        blurRadius: 8,
                        offset: const Offset(0, 2),
                      ),
                    ]
                  : null,
            ),
            child: Center(
              child: Text(
                emoji,
                style: const TextStyle(fontSize: 30),
              ),
            ),
          ),
          if (showLabels) ...[
            const SizedBox(height: 8),
            Text(
              label,
              style: Theme.of(context).textTheme.titleSmall?.copyWith(
                    color: isSelected ? color : AppColors.textSecondary,
                    fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
                  ),
            ),
          ],
        ],
      ),
    );
  }
} 